package org.lq.er.view.announcement;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

import org.lq.er.entity.Announcement;
import org.lq.er.service.impl.AnnouncementServiceImpl;

/**
 * 用户公告视图层
 * @author  张鹤山
 *
 */
public class User_announcement extends JPanel {

//	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					User_announcement frame = new User_announcement();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public User_announcement() {
		setBounds(100, 100, 450, 300);
		AnnouncementServiceImpl as = new AnnouncementServiceImpl();
		List<Announcement> list = as.findAll();
		StringBuffer text = new StringBuffer();
		for(int i = 0; i < list.size(); i++) {
			Announcement news = list.get(i);
			text.append(news.getInformation()+"\r\n发布时间："+news.getRelease_time()+"\t最后修改时间:"+news.getAlter_time()
			+"\r\n--------------------------------------------------------------------------------------------------------\r\n");
		}
		setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(134, 14, 2, 2);
		this.add(scrollPane);
		//		contentPane = new JPanel(null);
		//		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
				
				JTextArea textArea = new JTextArea();
				textArea.setBounds(10, 36, 419, 255);
				add(textArea);
				textArea.setEditable(false);
				textArea.setLineWrap(true);
				textArea.setText(text.toString());
		
		JLabel label = new JLabel("等级考试最新信息:");
		label.setIcon(new ImageIcon("image/timg.jpg"));
		label.setFont(new Font("宋体", Font.BOLD, 18));
		label.setBounds(151, 5, 167, 21);
		label.setOpaque(true);
		label.setBackground(new Color(247, 247, 247));
		this.add(label);
	}
}
